import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
import QtQuick.Dialogs 1.0
import AIClient.module 1.0

Page {
    id: trainjob_log
    title: "训练日志"
    visible: false
    width: parent.width*0.9
    height: parent.height*0.9

    function setlog(sdescription, slog)
    {
        description.text = sdescription
        log.text = slog
    }

    signal cancel()

    Rectangle{
        anchors.fill: parent
        color:"azure"
        width: trainjob_log.width
        height: trainjob_log.height
        GridLayout {
            anchors.topMargin: trainjob_log.height*0.05
            anchors.bottomMargin: trainjob_log.height*0.05
            anchors.leftMargin: trainjob_log.width*0.1
            anchors.rightMargin: trainjob_log.width*0.1
            anchors.fill: parent
            columnSpacing: 5
            rowSpacing: 15
            rows: 3
            columns: 1
            Rectangle {
                Layout.row: 0
                Layout.column: 0
                Layout.minimumHeight: 200
                Layout.maximumHeight: 300
                Layout.preferredHeight: 250
                Layout.fillWidth: true
                color: "white"

                Rectangle {
                    anchors.top: parent.top
                    height: 60
                    width: parent.width
//                    anchors.bottom: parent.top + 60
//                    anchors.left: parent.left
//                    anchors.right: parent.right
                    color: "aliceblue"
                    Text{
                        anchors.verticalCenter: parent.verticalCenter
                        text: "    详情"
                        color: "black"
                        font.pixelSize: 18
                        font.bold: true

                    }
                }

                ScrollView{
                    anchors.bottom: parent.bottom
                    width: parent.width
                    height: parent.height-60
//                    background: Rectangle{
//                        anchors.fill: parent
//                    //width: 500
//                        color: "white"
//                        //border.color: "black"
//                        //border.width: 1
//                    }
//                    anchors.bottom: parent.bottom
//                    anchors.left: parent.left
//                    anchors.right: parent.right
                //Layout.minimumWidth: 500
        //        Layout.fillHeight: true
        //        Layout.preferredHeight: 200
        //        Layout.minimumHeight: 12*2
        //        Layout.fillWidth: true
                    TextArea {
                        id: description
                        anchors.fill: parent
                        anchors.leftMargin: 15
                        anchors.rightMargin: 15
                        anchors.topMargin: 15
                        anchors.bottomMargin: 15
                        text: ""
                        selectByMouse: false
                        enabled: false
                        font.pixelSize: 16
                        background: Rectangle{
                            anchors.top: parent.top
                            height: 60
    //                        height: view_description.height
                        //width: 500
                            color: "transparent"
//                            border.color: "black"
//                            border.width: 1
                        }
                    }
                }
            }

            Rectangle {
                Layout.row: 1
                Layout.column: 0
               //Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.fillHeight: true
                Layout.minimumHeight: 350
                Layout.maximumHeight: 800
                Layout.preferredHeight: 600
                color: "white"

                Rectangle {
                    anchors.top: parent.top
                    height: 60
                    width: parent.width
//                    anchors.bottom: parent.top + 60
//                    anchors.left: parent.left
//                    anchors.right: parent.right
                    color: "aliceblue"
                    Text{
                        anchors.verticalCenter: parent.verticalCenter
                        //anchors.leftMargin: 20
                        text: "    消息"
                        color: "black"
                        font.pixelSize: 18
                        font.bold: true

                    }
                }

                ScrollView{
                    anchors.bottom: parent.bottom
                    width: parent.width
                    height: parent.height-60
                    id: view_description
//                    background: Rectangle{
//                        anchors.fill: view_description
////                        height: view_description.height
//                    //width: 500
//                        color: "white"
//                        border.color: "black"
//                        border.width: 1
//                    }
//                    anchors.bottom: parent.bottom
//                    anchors.left: parent.left
//                    anchors.right: parent.right
                //Layout.minimumWidth: 500
        //        Layout.fillHeight: true
        //        Layout.preferredHeight: 200
        //        Layout.minimumHeight: 12*2
        //        Layout.fillWidth: true
                    TextArea {
                        id: log
                        anchors.fill: parent
                        anchors.leftMargin: 15
                        anchors.rightMargin: 15
                        anchors.topMargin: 15
                        anchors.bottomMargin: 15
//                        anchors.fill: parent
                        text: ""
                        selectByMouse: false
                        enabled: false
                        font.pixelSize: 16
                        background: Rectangle{
                            anchors.top: parent.top
                            height: 60
    //                        height: view_description.height
                        //width: 500
                            color: "transparent"
//                            border.color: "black"
//                            border.width: 1
                        }
                        //placeholderText: qsTr("Enter description")
                        //placeholderTextColor: "white"

//                        background:
                        //Component.onCompleted: {
                            //log.placeholderText=""
                        //}

                    }
                }
            }
            Rectangle {
                Layout.row: 2
                Layout.column: 0
                Layout.fillWidth: true
//                Layout.fillHeight: true
                Layout.preferredHeight: 60
                //Layout.minimumHeight: 60
                Layout.maximumHeight: 60
                color: "azure"
                Button {
                    anchors.centerIn: parent
                    width: 180
                    text:"返回"
                    font.pixelSize: Qt.application.font.pixelSize*1.2
                    background: Rectangle {
                        anchors.fill: parent
                        color: "gold"
                        border.color: "black"
                        border.width: parent.hovered?0:2
                        radius: 5
                    }
                    hoverEnabled: true

                    onClicked: {
                        cancel()
                    }
                }
            }

        }
    }


}
